package br.usp.wta.aux;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;

public class ProcessFile {
    
    private static final String FOLDER = "resources/training/";
    private static final String FILENAME = "news_out.txt";
    
    public static void main(String[] args) {
        try {
            FileReader reader = new FileReader(FOLDER + FILENAME);
            FileWriter writer = new FileWriter(FOLDER + "realtraining/" + FILENAME);
            
            boolean copying = false;
            while (reader.ready()) {
                int read = reader.read();
                if (read == '(') {
                   copying = true;
                } else if (read == ')') {
                   copying = false;
                   writer.write(" ");
                } else if (read == '\n') {
                    writer.write(System.getProperty("line.separator"));
                } else if (copying) {
                   writer.write(read); 
                }
            }
            
            reader.close();
            writer.close();
                
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }

}
